package be.ipl.domaine;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;


/**
 * The Class Case.
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "Case", schema = "finito")
public class Case implements Serializable {
	
	/** The id_case. */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id_case;
	
	/** The position. */
	@Column
	@NotNull
	@Min(0)
	@Max(35)
	private int position;
	
	/** The jeton. */
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="ID_JETON")
	private Jeton jeton;
	
	/** The tableau. */
	@ManyToOne
	@JoinColumn(name = "ID_TABLEAU")
	private Tableau tableau;

	/**
	 * Instantiates a new case.
	 */
	protected Case() {
	}

	/**
	 * Instantiates a new case.
	 *
	 * @param position the position
	 * @param jeton the jeton
	 */
	public Case(int position, Jeton jeton) {
		this.jeton = jeton;
		this.position = position;
	}

	/**
	 * Gets the position.
	 *
	 * @return the position
	 */
	public int getPosition() {
		return position;
	}

	/**
	 * Sets the position.
	 *
	 * @param position the new position
	 */
	public void setPosition(int position) {
		this.position = position;
	}

	/**
	 * Gets the id_case.
	 *
	 * @return the id_case
	 */
	public int getId_case() {
		return id_case;
	}

	/**
	 * Sets the id_case.
	 *
	 * @param id_case the new id_case
	 */
	public void setId_case(int id_case) {
		this.id_case = id_case;
	}

	/**
	 * Gets the jeton.
	 *
	 * @return the jeton
	 */
	public Jeton getJeton() {
		return jeton;
	}

	/**
	 * Sets the jeton.
	 *
	 * @param jeton the new jeton
	 */
	public void setJeton(Jeton jeton) {
		this.jeton = jeton;
	}

	/**
	 * Gets the tableau.
	 *
	 * @return the tableau
	 */
	public Tableau getTableau() {
		return tableau;
	}

	/**
	 * Sets the tableau.
	 *
	 * @param tableau the new tableau
	 */
	public void setTableau(Tableau tableau) {
		this.tableau = tableau;
	}

	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_case;
		return result;
	}

	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (id_case != other.id_case)
			return false;
		return true;
	}

}
